import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text("cached_network_image"),
        ),
        body: Center(
          child: CachedNetworkImage(
            height: 40,
            width: 40,
            fit: BoxFit.fill,
            imageUrl: "https://github.com/flutter/plugins/raw/master/packages/video_player/doc/demo_ipod.gif?raw=true",
            placeholder: (context, url) => Image.asset(
              "assets/images/cover_img.jpg",
              height: 40,
              width: 40,
              fit: BoxFit.fill,
            ),
            errorWidget: (context, url, error) => Image.asset(
              "assets/images/img1.jpg",
              height: 40,
              width: 40,
              fit: BoxFit.fill,
            ),
          ),
        ),
      ),
    );
  }
}
